package com.unidt.www.module.third.doc.controller.admin;

import com.unidt.www.framework.common.pojo.CommonResult;
import com.unidt.www.module.third.doc.service.IDocService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * @Author sk
 * @Description:
 * @Date 2022/11/24 11:45
 **/

@Api(tags = "管理后台-文档解析")
@RestController
@RequestMapping("/doc/api")
public class DocController {


    @Autowired
    IDocService iDocService;

    @PostMapping("/upload")
    @ApiOperation("文档上传")
    public CommonResult upload(@RequestParam(value = "file") MultipartFile file)  {

        return CommonResult.success(iDocService.upload(file));

    }


    @PutMapping("/parse/{docId}")
    @ApiOperation("解析入库")
    public CommonResult parse(@PathVariable(value = "docId") Long docId) {

        this.iDocService.parse(docId);
        return CommonResult.success("解析成功");
    }


    @GetMapping("/getParse/{docId}")
    @ApiOperation("获取解析详情")
    public CommonResult getParse(@PathVariable(value = "docId") Long docId) {
        return CommonResult.success(this.iDocService.getParse(docId));
    }







}
